package com.ruoyi.manage.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.manage.mapper.PurchasePlanMapper;
import com.ruoyi.manage.domain.PurchasePlan;
import com.ruoyi.manage.service.IPurchasePlanService;

/**
 * 采购计划Service业务层处理
 * 
 * @author rjgc-17
 * @date 2024-12-25
 */
@Service
public class PurchasePlanServiceImpl implements IPurchasePlanService 
{
    @Autowired
    private PurchasePlanMapper purchasePlanMapper;

    /**
     * 查询采购计划
     * 
     * @param id 采购计划主键
     * @return 采购计划
     */
    @Override
    public PurchasePlan selectPurchasePlanById(Long id)
    {
        return purchasePlanMapper.selectPurchasePlanById(id);
    }

    /**
     * 查询采购计划列表
     * 
     * @param purchasePlan 采购计划
     * @return 采购计划
     */
    @Override
    public List<PurchasePlan> selectPurchasePlanList(PurchasePlan purchasePlan)
    {
        return purchasePlanMapper.selectPurchasePlanList(purchasePlan);
    }

    /**
     * 新增采购计划
     * 
     * @param purchasePlan 采购计划
     * @return 结果
     */
    @Override
    public int insertPurchasePlan(PurchasePlan purchasePlan)
    {
        purchasePlan.setCreateTime(DateUtils.getNowDate());
        purchasePlan.setCreateBy(SecurityUtils.getUsername());
        purchasePlan.setPlanTime(DateUtils.getNowDate());
        return purchasePlanMapper.insertPurchasePlan(purchasePlan);
    }

    /**
     * 修改采购计划
     * 
     * @param purchasePlan 采购计划
     * @return 结果
     */
    @Override
    public int updatePurchasePlan(PurchasePlan purchasePlan)
    {
        purchasePlan.setUpdateTime(DateUtils.getNowDate());
        purchasePlan.setUpdateBy(SecurityUtils.getUsername());
        return purchasePlanMapper.updatePurchasePlan(purchasePlan);
    }

    /**
     * 批量删除采购计划
     * 
     * @param ids 需要删除的采购计划主键
     * @return 结果
     */
    @Override
    public int deletePurchasePlanByIds(Long[] ids)
    {
        return purchasePlanMapper.deletePurchasePlanByIds(ids);
    }

    /**
     * 删除采购计划信息
     * 
     * @param id 采购计划主键
     * @return 结果
     */
    @Override
    public int deletePurchasePlanById(Long id)
    {
        return purchasePlanMapper.deletePurchasePlanById(id);
    }
}
